I tried saving Twilio Programmable Video recordings in S3

I tried saving Twilio Programmable Video recordings in S3

Clock Icon2023.03.06

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Twilio is a cloud communications platform that allows software developers to programmatically make and receive phone calls, send and receive text messages, and perform other communication functions using its Application Programming Interfaces (APIs).

Prerequisites-

1. Twilio Account

2. Twilio Programmable Video setup

3. AWS account

Let's start-

To save the recordings to an external S3 bucket, we have to enable few settings.

Let's make a S3 bucket with required permissions. The S3 bucket in which we have to store the recordings should only have 'PutObject' permission. For that we have to make a new IAM user with S3PutObjectPolicy.

Make a new IAM user by clicking on the Users tab.

Add user name and all the other necessary details, then select 'next' button.

Here comes the main part. We have to give ONLY 's3PutObjectPolicy' policy. Twilio will generate error if we'll provide any other permission or attach any other policy other than this.

Select Attach existing policies directly and press the Create policy button to configure the user permissions. After that, select Create policy, pick the JSON editor and create a policy document with write permissions. You can use the following JSON snippet as a template for the policy document.


{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "UploadUserDenyEverything",
            "Effect": "Deny",
            "NotAction": "*",
            "Resource": "*"
        },
        {
            "Sid": "UploadUserAllowPutObject",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::my_bucket_name/*"
            ]
        }
    ]
}

In the above policy, replace my_bucket_name at the bottom of the snippet with the actual bucket-name.

After this, we just have to review and Create User. Don't forget to store the access key and secret access key and also download the .csv file for future use.

Let's go to S3 now.

Create a new bucket and give your desired bucket name. Keep all the other settings as default.

Get the S3 URL which has the following format- https://my-new-bucket.s3-us-east-2.amazonaws.com

Note that bucket-name is the name of your bucket and that you must replace aws-region-code with the AWS region code corresponding to your bucket-region.

Save everything we did until now.

Let's go to Twilio and go to 'Programmable Video' option. Under Video, let's go to 'Manage'>'Recording Settings'. Click on 'Add new credential' tab and enter an appropriate friendly name, IAM user Access Key Id and Secret Access Key.

Next, let's add the endpoint URL of the S3 bucket we created earlier.

Then click on 'Save' button. Now, whenever you will run your Twilio Video and record the video, your recordings will be saved in your S3 bucket.

I hope this article will help you understand Twilio better. In case of any question, please drop a comment below. Thank you for your time.

Happy Learning!

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.